<template>
  <div>
    <base-search
      :title="'加入企业申请'"
      :schema="search"
      :isShowSearch="selectionRowData.length"
      @search-submit="searchSubmit"
      @reset-submit="resetSubmit"
      v-permission="['home.msglist.notice.see']"
    ></base-search>
    <base-table
      ref="tableRefCom"
      v-loading="loading"
      border
      :row-style="{ cursor: 'pointer' }"
      row-key="id"
      rowKey="id"
      :columns="searchClumon"
      :data="tableData"
      v-permission="['home.msglist.notice.see']"
      :pagination="{
        currentPage: defaultParams.page,
        total: total,
        onSizeChange: handleSizeChange,
        onCurrentChange: handleCurrentChange
      }"
    >
      <template #action="scope">
        <el-button type="text" style="color:#3487e2" @click="handelPass(scope.row)">通过</el-button>
        <el-button type="text" style="color:red" @click="textareaModelClick(scope.row)">拒绝</el-button>
      </template>
    </base-table>
    <textarea-model
      ref="textareaModelChild"
      :autosize="{ minRows: 4, maxRows: 5 }"
      :textareaModelObj="textareaModelObj"
      :descriptionFalg="descriptionFalg"
      @textareaModel-submit="textareaModelSubmit"
    ></textarea-model>
    <pass-dialog ref="passDialogRef"></pass-dialog>
  </div>
</template>

<script setup>
import { onActivated, ref, reactive, nextTick } from 'vue'
// import ZcbSearch from 'components/zcb-search'
// import BasicTable from 'components/table/basicTable.vue'
import { useMock } from './hooks/useSearch'
import { useBasicData } from './hooks/useBasicData'
import { webmsgListApi } from 'api/common/message'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import textareaModel from '../personalCenter/component/textareaModel.vue'
import passDialog from './components/passDialog.vue'
const { t } = useI18n()
const { search, searchClumon } = useMock()
const router = useRouter()
const textareaModelChild = ref()
const descriptionFalg = ref(false)
const passDialogRef = ref()
const {
  defaultParams,
  tableData,
  loading,
  total,
  tableRefCom,
  selectionRowData,
  handleSizeChange,
  handleCurrentChange,
  getList,
  onRowClick,
  handleSelectionChange,
  searchSubmit,
  resetSubmit,
  deletePopConfirm
} = useBasicData({
  listFun: webmsgListApi
})
const textareaModelObj = reactive({
  title: '',
  copywriting: '', // 文案
  copywritingBill: '' // span包裹的文案
})
getList()
onActivated(() => {
  getList()
})
const onClick = (row) => {
  router.push({
    path: '/notice/previewContent',
    query: {
      id: row?.id,
      readFlag: row?.readFlag
    }
  })
}

// 拒绝
const textareaModelClick = (row) => {
  descriptionFalg.value = true
  // 拒绝
  textareaModelObj.title = '提示'
  textareaModelObj.copywriting = `确认拒绝该条申请吗？`
  textareaModelObj.label = '备注'
  nextTick(() => {
    textareaModelChild.value.showModel()
  })
}

// 拒绝确认回调
const textareaModelSubmit = (res) => {}

// 通过
const handelPass = (row) => {
  passDialogRef.value.showDialog()
}
</script>

<style lang="scss" scoped>
.istop {
  background: #fff3e8;
  border-radius: 2px;
  border: 1px solid #ff6700;
  font-size: 12px;
  font-weight: 500;
  color: #ff6700;
  line-height: 1;
  width: 32px;
  height: 16px;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
</style>
